package com.zj.study.utils.validation.validator.repeat;


import com.zj.study.utils.validation.annotation.ValidateSupport;
import java.util.HashSet;
import java.util.List;
import org.springframework.lang.NonNull;

/**
 * @author 谭耀飞
 * @since 2020.12.0
 */
@ValidateSupport(List.class)
public class NotRepeatValidatorForList extends AbstractNotRepeatValidator<List<?>> {

  @Override
  boolean compare(@NonNull List<?> value) {
    return value.size() < 2 || new HashSet<>(value).size() == value.size();
  }

}
